﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace GA.Server.ApiInfo
{
    [Serializable]
    public class ApiKill
    {
        public string DeviceName { get; private set; }
        public int KillCount { get; private set; }
        public DateTime TimeStamp { get; private set; }
        public string Name { get; private set; }
        public int PlayerId { get; private set; }
        public string Victim { get; private set; }
        public string VictimClass { get; private set; }
        public int KillByCount { get; private set; }
        public string KillerClass { get; private set; }
        public string Killer { get; private set; }

        public ApiKill()
        {
        }

        public ApiKill(XmlReader reader)
        {
            while (!reader.EOF)
            {
                reader.Read();
                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                        case "a:device_name": DeviceName = ApiXmlNode.GetValue(reader); break;
                        case "a:kill_cnt": KillCount = int.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:name": Name = ApiXmlNode.GetValue(reader); break;
                        case "a:victim": Victim = ApiXmlNode.GetValue(reader); break;
                        case "a:victim_class": VictimClass = ApiXmlNode.GetValue(reader); break;
                        case "a:killed_by_cnt": KillByCount = int.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:killer_class": KillerClass = ApiXmlNode.GetValue(reader); break;
                        case "a:killer_player": Killer = ApiXmlNode.GetValue(reader); break;
                        case "a:kill_timestamp": TimeStamp = DateTime.Parse(ApiXmlNode.GetValue(reader)); break;
                    }
                }
            }
        }
    }
}
